<?php


abstract class BaseLog extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $id;


	
	protected $parent_id;


	
	protected $project_id;


	
	protected $class_name;


	
	protected $action;


	
	protected $obj_id;


	
	protected $obj_name;


	
	protected $md5;


	
	protected $user_id;


	
	protected $created_at;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getId()
	{

		return $this->id;
	}

	
	public function getParentId()
	{

		return $this->parent_id;
	}

	
	public function getProjectId()
	{

		return $this->project_id;
	}

	
	public function getClassName()
	{

		return $this->class_name;
	}

	
	public function getAction()
	{

		return $this->action;
	}

	
	public function getObjId()
	{

		return $this->obj_id;
	}

	
	public function getObjName()
	{

		return $this->obj_name;
	}

	
	public function getMd5()
	{

		return $this->md5;
	}

	
	public function getUserId()
	{

		return $this->user_id;
	}

	
	public function getCreatedAt($format = 'Y-m-d H:i:s')
	{

		if ($this->created_at === null || $this->created_at === '') {
			return null;
		} elseif (!is_int($this->created_at)) {
			
			$ts = strtotime($this->created_at);
			if ($ts === -1 || $ts === false) { 
				throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true));
			}
		} else {
			$ts = $this->created_at;
		}
		if ($format === null) {
			return $ts;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $ts);
		} else {
			return date($format, $ts);
		}
	}

	
	public function setId($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->id !== $v) {
			$this->id = $v;
			$this->modifiedColumns[] = LogPeer::ID;
		}

	} 

	
	public function setParentId($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->parent_id !== $v) {
			$this->parent_id = $v;
			$this->modifiedColumns[] = LogPeer::PARENT_ID;
		}

	} 

	
	public function setProjectId($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->project_id !== $v) {
			$this->project_id = $v;
			$this->modifiedColumns[] = LogPeer::PROJECT_ID;
		}

	} 

	
	public function setClassName($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->class_name !== $v) {
			$this->class_name = $v;
			$this->modifiedColumns[] = LogPeer::CLASS_NAME;
		}

	} 

	
	public function setAction($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->action !== $v) {
			$this->action = $v;
			$this->modifiedColumns[] = LogPeer::ACTION;
		}

	} 

	
	public function setObjId($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->obj_id !== $v) {
			$this->obj_id = $v;
			$this->modifiedColumns[] = LogPeer::OBJ_ID;
		}

	} 

	
	public function setObjName($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->obj_name !== $v) {
			$this->obj_name = $v;
			$this->modifiedColumns[] = LogPeer::OBJ_NAME;
		}

	} 

	
	public function setMd5($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->md5 !== $v) {
			$this->md5 = $v;
			$this->modifiedColumns[] = LogPeer::MD5;
		}

	} 

	
	public function setUserId($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->user_id !== $v) {
			$this->user_id = $v;
			$this->modifiedColumns[] = LogPeer::USER_ID;
		}

	} 

	
	public function setCreatedAt($v)
	{

		if ($v !== null && !is_int($v)) {
			$ts = strtotime($v);
			if ($ts === -1 || $ts === false) { 
				throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true));
			}
		} else {
			$ts = $v;
		}
		if ($this->created_at !== $ts) {
			$this->created_at = $ts;
			$this->modifiedColumns[] = LogPeer::CREATED_AT;
		}

	} 

	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->id = $rs->getInt($startcol + 0);

			$this->parent_id = $rs->getInt($startcol + 1);

			$this->project_id = $rs->getInt($startcol + 2);

			$this->class_name = $rs->getString($startcol + 3);

			$this->action = $rs->getString($startcol + 4);

			$this->obj_id = $rs->getInt($startcol + 5);

			$this->obj_name = $rs->getString($startcol + 6);

			$this->md5 = $rs->getString($startcol + 7);

			$this->user_id = $rs->getInt($startcol + 8);

			$this->created_at = $rs->getTimestamp($startcol + 9, null);

			$this->resetModified();

			$this->setNew(false);

			
			return $startcol + 10; 

		} catch (Exception $e) {
			throw new PropelException("Error populating Log object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(LogPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			LogPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
    if ($this->isNew() && !$this->isColumnModified(LogPeer::CREATED_AT))
    {
      $this->setCreatedAt(time());
    }

		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(LogPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 
		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


			
			if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = LogPeer::doInsert($this, $con);
					$affectedRows += 1; 
										 
										 

					$this->setId($pk);  

					$this->setNew(false);
				} else {
					$affectedRows += LogPeer::doUpdate($this, $con);
				}
				$this->resetModified(); 
			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 

	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


			if (($retval = LogPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}



			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = LogPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getId();
				break;
			case 1:
				return $this->getParentId();
				break;
			case 2:
				return $this->getProjectId();
				break;
			case 3:
				return $this->getClassName();
				break;
			case 4:
				return $this->getAction();
				break;
			case 5:
				return $this->getObjId();
				break;
			case 6:
				return $this->getObjName();
				break;
			case 7:
				return $this->getMd5();
				break;
			case 8:
				return $this->getUserId();
				break;
			case 9:
				return $this->getCreatedAt();
				break;
			default:
				return null;
				break;
		} 
	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = LogPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getId(),
			$keys[1] => $this->getParentId(),
			$keys[2] => $this->getProjectId(),
			$keys[3] => $this->getClassName(),
			$keys[4] => $this->getAction(),
			$keys[5] => $this->getObjId(),
			$keys[6] => $this->getObjName(),
			$keys[7] => $this->getMd5(),
			$keys[8] => $this->getUserId(),
			$keys[9] => $this->getCreatedAt(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = LogPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setId($value);
				break;
			case 1:
				$this->setParentId($value);
				break;
			case 2:
				$this->setProjectId($value);
				break;
			case 3:
				$this->setClassName($value);
				break;
			case 4:
				$this->setAction($value);
				break;
			case 5:
				$this->setObjId($value);
				break;
			case 6:
				$this->setObjName($value);
				break;
			case 7:
				$this->setMd5($value);
				break;
			case 8:
				$this->setUserId($value);
				break;
			case 9:
				$this->setCreatedAt($value);
				break;
		} 
	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = LogPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setParentId($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setProjectId($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setClassName($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setAction($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setObjId($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setObjName($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setMd5($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setUserId($arr[$keys[8]]);
		if (array_key_exists($keys[9], $arr)) $this->setCreatedAt($arr[$keys[9]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(LogPeer::DATABASE_NAME);

		if ($this->isColumnModified(LogPeer::ID)) $criteria->add(LogPeer::ID, $this->id);
		if ($this->isColumnModified(LogPeer::PARENT_ID)) $criteria->add(LogPeer::PARENT_ID, $this->parent_id);
		if ($this->isColumnModified(LogPeer::PROJECT_ID)) $criteria->add(LogPeer::PROJECT_ID, $this->project_id);
		if ($this->isColumnModified(LogPeer::CLASS_NAME)) $criteria->add(LogPeer::CLASS_NAME, $this->class_name);
		if ($this->isColumnModified(LogPeer::ACTION)) $criteria->add(LogPeer::ACTION, $this->action);
		if ($this->isColumnModified(LogPeer::OBJ_ID)) $criteria->add(LogPeer::OBJ_ID, $this->obj_id);
		if ($this->isColumnModified(LogPeer::OBJ_NAME)) $criteria->add(LogPeer::OBJ_NAME, $this->obj_name);
		if ($this->isColumnModified(LogPeer::MD5)) $criteria->add(LogPeer::MD5, $this->md5);
		if ($this->isColumnModified(LogPeer::USER_ID)) $criteria->add(LogPeer::USER_ID, $this->user_id);
		if ($this->isColumnModified(LogPeer::CREATED_AT)) $criteria->add(LogPeer::CREATED_AT, $this->created_at);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(LogPeer::DATABASE_NAME);

		$criteria->add(LogPeer::ID, $this->id);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getId();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setId($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setParentId($this->parent_id);

		$copyObj->setProjectId($this->project_id);

		$copyObj->setClassName($this->class_name);

		$copyObj->setAction($this->action);

		$copyObj->setObjId($this->obj_id);

		$copyObj->setObjName($this->obj_name);

		$copyObj->setMd5($this->md5);

		$copyObj->setUserId($this->user_id);

		$copyObj->setCreatedAt($this->created_at);


		$copyObj->setNew(true);

		$copyObj->setId(NULL); 

	}

	
	public function copy($deepCopy = false)
	{
		
		$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new LogPeer();
		}
		return self::$peer;
	}

} 
